package com.adlotto2.lcdns.activity.notify;

import org.w3c.dom.Element;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;

import com.adlotto2.lcdns.R;
import com.adlotto2.lcdns.activity.ad.request.LottoAdRequestActivity;
import com.adlotto2.lcdns.common.BaseActivity;
import com.adlotto2.lcdns.util.ApplicationUtils;
import com.adlotto2.lcdns.util.LottoAdConstants;
import com.adlotto2.lcdns.util.LottoAdOverButton;

/**
 * 공지사항 - Main Activity
 * @author Administrator
 *
 */
public class LottoAdNotifyMainActivity extends BaseActivity{
	private Context mContext;
	
	/**카카오톡 친구추천 버튼*/
	private Button mKakaoBtn;
	/**공지사항 Button**/
	private Button mNotiBtn;
	/**FAQ Button**/
	private Button mFaQBtn;
	/**당첨현황 Button**/
	private Button mlotteryBtn;
	/**제휴회사 Button**/
	private Button mPartnerBtn;
	
	/*####### Ben ########*/
	// 광고신청 버튼
	private Button mRequestAdBtn;
	
	@Override
	protected int onGetContentViewResource() {
		return R.layout.lottoad_menu_notify;
	}

	@Override
	protected void onInit() {
		this.mContext = this;
		
		mKakaoBtn = (Button) findViewById(R.id.button_kakao);
		mNotiBtn = (Button) findViewById(R.id.button_notify);
		mFaQBtn = (Button) findViewById(R.id.button_faq);
		mlotteryBtn = (Button) findViewById(R.id.button_lottery);
		mPartnerBtn = (Button) findViewById(R.id.button_partner);
		mRequestAdBtn = (Button) findViewById(R.id.btn_notify_request_ad);
		
		mNotiBtn.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				Drawable getBackground = v.getBackground();
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					v.setBackgroundDrawable(LottoAdOverButton.grayimg(getBackground));
				}
				else if(event.getAction() == MotionEvent.ACTION_UP){
					getBackground.clearColorFilter();
					v.setBackgroundDrawable(getBackground);
					Intent intent = new Intent(mContext, LottoAdNotifyActivity.class);
					startActivity(intent);
				}
				return false;
			}
		});
		
		mFaQBtn.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				Drawable getBackground = v.getBackground();
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					v.setBackgroundDrawable(LottoAdOverButton.grayimg(getBackground));
				}
				else if(event.getAction() == MotionEvent.ACTION_UP){
					getBackground.clearColorFilter();
					v.setBackgroundDrawable(getBackground);
					Intent intent = new Intent(mContext, LottoAdFaqActivity.class);
					startActivity(intent);
				}
				return false;
			}
		});
		
		mlotteryBtn.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				Drawable getBackground = v.getBackground();
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					v.setBackgroundDrawable(LottoAdOverButton.grayimg(getBackground));
				}
				else if(event.getAction() == MotionEvent.ACTION_UP){
					getBackground.clearColorFilter();
					v.setBackgroundDrawable(getBackground);
					Intent intent = new Intent(mContext, LottoAdWinnerActivity.class);
					startActivity(intent);
				}
				return false;
			}
		});
		
		mPartnerBtn.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				Drawable getBackground = v.getBackground();
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					v.setBackgroundDrawable(LottoAdOverButton.grayimg(getBackground));
				}
				else if(event.getAction() == MotionEvent.ACTION_UP){
					getBackground.clearColorFilter();
					v.setBackgroundDrawable(getBackground);
					Intent intent = new Intent(mContext, LottoAdPartnerListActivity.class);
					startActivity(intent);
				}
				return false;
			}
		});
		
		mRequestAdBtn.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				Drawable getBackground = v.getBackground();
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					v.setBackgroundDrawable(LottoAdOverButton.grayimg(getBackground));
				}
				else if(event.getAction() == MotionEvent.ACTION_UP){
					getBackground.clearColorFilter();
					v.setBackgroundDrawable(getBackground);
					Intent intent = new Intent(mContext, LottoAdRequestActivity.class);
					startActivity(intent);
				}
				return false;
			}
		});
		
		mKakaoBtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				ApplicationUtils.checkPackage(mContext, LottoAdConstants.KAKAO_PACKAGE_NAME);
			}
		});
	}
	
	@Override
	public void onAsyncPreRequest() {
		
	}

	@Override
	public void onAsyncRequestCompleted(Element xmlObject) {
		
	}

	@Override
	public void onAsyncCancelRequest() {
		
	}

	@Override
	public String onGetAsyncRequestUrl() {
		return null;
	}

	@Override
	public void onAsyncRequestError(int paramInt) {
		
	}

	@Override
	public void onAsyncDataError(Element paramXMLObject, String paramString) {
		
	}
}
